package riot.challenge.java.statistics;

import riot.challenge.java.interfaces.IHistoricalPlayerStatistics;
import riot.challenge.java.interfaces.IStatistics;

public class HistoricalPlayerStatistics implements IStatistics, IHistoricalPlayerStatistics{

	// Variables declaration
	
	private int win;
	private int lost;
	private int totalNumberOfGamePlayed;
	private long totalDurationOfGamePlayed;
	private int totalNumberOfKills;
	
	// End of Variables declaration
	
	/**
	 * Constructor (default)
	 */
	public HistoricalPlayerStatistics() {
		
		this.win = 0;
		this.lost = 0;
		this.totalNumberOfGamePlayed = 0;
		this.totalDurationOfGamePlayed = 0;
		this.totalNumberOfKills = 0;
	}

	// Accessors and Mutators
	
	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#getWin()
	 */
	@Override
	public int getWin() {
		return win;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#setWin(int)
	 */
	@Override
	public void setWin(int win) {
		this.win = win;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#getLost()
	 */
	@Override
	public int getLost() {
		return lost;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#setLost(int)
	 */
	@Override
	public void setLost(int lost) {
		this.lost = lost;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#getTotalNumberOfGamePlayed()
	 */
	@Override
	public int getTotalNumberOfGamePlayed() {
		return totalNumberOfGamePlayed;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#setTotalNumberOfGamePlayed(int)
	 */
	@Override
	public void setTotalNumberOfGamePlayed(int totalNumberOfGamePlayed) {
		this.totalNumberOfGamePlayed = totalNumberOfGamePlayed;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#getTotalDurationOfGamePlayed()
	 */
	@Override
	public long getTotalDurationOfGamePlayed() {
		return totalDurationOfGamePlayed;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#setTotalDurationOfGamePlayed(long)
	 */
	@Override
	public void setTotalDurationOfGamePlayed(long totalDurationOfGamePlayed) {
		this.totalDurationOfGamePlayed = totalDurationOfGamePlayed;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#getTotalNumberOfKills()
	 */
	@Override
	public int getTotalNumberOfKills() {
		return totalNumberOfKills;
	}

	/* (non-Javadoc)
	 * @see riot.challenge.java.model.IHistoricalPlayerStatistics#setTotalNumberOfKills(int)
	 */
	@Override
	public void setTotalNumberOfKills(int totalNumberOfKills) {
		this.totalNumberOfKills = totalNumberOfKills;
	}
	
	// End of Accessors and Mutators
	
	/* (non-Javadoc)
	 * @see riot.challenge.java.interfaces.IHistoricalPlayerStatistics#update(boolean, long, int)
	 */
	public void update(boolean isVictorious, long durationOfGamePlayed, int numberOfKills) {
		
		if(durationOfGamePlayed != 0) {
			
			this.totalNumberOfGamePlayed++;
			
			if(isVictorious)
				this.win++;
			else
				this.lost++;
			
			this.totalDurationOfGamePlayed += durationOfGamePlayed;
			
			this.totalNumberOfKills += numberOfKills;
		}
	}
}
